package org.nViron.Graffiti;

import instar.dg.Common.Position;
import instar.dg.Profile.FriendPosition;

public class Util {

	public static LonLat transformLonLatToMercatorProjection(FriendPosition toBeTransformed){
		double lon = toBeTransformed.getPosition().getLongitude();
		double lat = toBeTransformed.getPosition().getLatitude();
		
		double lonResult = lon * 20037508.34 / 180;
		double latResult = Math.log(Math.tan((90 + lat) * Math.PI/360)) / Math.PI * 20037508.34;

		return new LonLat(lonResult, latResult);
	}
	
	public static LonLat transformLonLatToMercatorProjection(Position toBeTransformed){
		double lon = toBeTransformed.getLongitude();
		double lat = toBeTransformed.getLatitude();
		
		double lonResult = lon * 20037508.34 / 180;
		double latResult = Math.log(Math.tan((90 + lat) * Math.PI/360)) / Math.PI * 20037508.34;

		return new LonLat(lonResult, latResult);
	}
	
	public static LonLat getLonLatFromPosition(Position pos){
		return new LonLat(pos.getLongitude(), pos.getLatitude());
	}

}